<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>图书类型页面</title>
<link rel="stylesheet" type="text/css"
	href="../jquery/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../jquery/themes/icon.css">
<script type="text/javascript" src="../jquery/jquery.min.js"></script>
<script type="text/javascript" src="../jquery/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../jquery/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	$(function() {

		$("#btn-add").click(function() {
			$("#add-dialog").dialog({
				closed : false,
				buttons : [ {
					text : '保存',
					iconCls : 'icon-save',
					handler : function() {
						$('#add-form').form('submit', {
							url : '../saveBookInfo',
							onSubmit : function() {
								return $('#add-form').form('validate');
							},
							success : function(flag) {
								if (flag == 1) {
									$('#add-form').form('clear');
									$.messager.show({
										title : '信息提示',
										msg : '操作成功',
										timeout : 5000,
										showType : 'slide'
									});
									$("#add-dialog").dialog({
										closed : true
									});

									$("#dg").datagrid('load');

								} else if (flag == 0) {
									$.messager.show({
										title : '信息提示',
										msg : '操作失败',
										timeout : 5000,
										showType : 'slide'
									});
								} else if (flag == -1) {
									alert('该类型已存在,不能再次进行添加');
								}
							}
						});

					}
				}, {
					text : '重置',
					iconCls : 'icon-redo',
					handler : function() {
						$("#add-form").form('clear');

					}
				}, {
					text : '关闭',
					iconCls : 'icon-cancel',
					handler : function() {
						$("#add-form").form('clear');
						$("#add-dialog").dialog({
							closed : true
						})
					}
				} ]
			})

		})
		$("#btn-search").click(function(){
			$('#dg').datagrid('load',{
				bNum:$("#bNum").val(),
				bName:$("#bName").val(),
				author:$("#author").val(),
				publish:$("#publish").val()
			})
		})
		
		$('#dg').datagrid({
			url : '../findBookWithPage',
			fit : true,
			fitColumns : true,
			pagination : true,
			nowrap : false,
			toolbar : '#tb',
			pagePosition : 'both',
			columns : [ [ {
				field : 'bId',
				title : '图书ID',
				width : 100,
				checkbox : true
			}, {
				field : 'bNum',
				title : '图书编号',
				width : 100
			}, {
				field : 'bName',
				title : '图书名称',
				width : 100
			}, {
				field : 'price',
				title : '图书单价',
				width : 100
			}, {
				field : 'publish',
				title : '出版社',
				width : 100
			}, {
				field : 'publishDate',
				title : '出版日期',
				width : 100
			}, {
				field : 'author',
				title : '作者',
				width : 100
			}, {
				field : 'categoryName',
				title : '分类名称',
				width : 100
			}, {
				field : 'uname',
				title : '录入人',
				width : 100
			}, {
				field : 'createDate',
				title : '入库时间',
				width : 100
			}

			] ]
		});

	})
</script>
</head>
<body>
	<div id="tb">
		<table>
			<tr>
				<td>图书编号:</td>
				<td><input id="bNum" class="easyui-validatebox" /></td>
				<td>图书名称:</td>
				<td><input id="bName" class="easyui-validatebox" /></td>
			</tr>
			<tr>
				<td>出版社:&nbsp;&nbsp;</td>
				<td><input id="publish" class="easyui-validatebox" /></td>
				<td>作&nbsp;&nbsp;&nbsp;&nbsp;者:</td>
				<td><input id="author" class="easyui-validatebox" /><a
					id="btn-search" href="#" class="easyui-linkbutton"
					data-options="plain:true,iconCls:'icon-search'">查询</a></td>
			</tr>


		</table>
		<a id="btn-add" href="#" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-add'">添加图书信息</a> <a
			id="btn-edit" href="#" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-edit'">修改图书信息</a> <a
			id="btn-remove" href="#" class="easyui-linkbutton"
			data-options="plain:true,iconCls:'icon-remove'">删除图书信息</a>
	</div>



	<div id="dg"></div>

	<div id="add-dialog" class="easyui-dialog" title="添加类型信息"
		style="width: auto; height: auto;"
		data-options="modal:true,closed:true,closable:false">
		<form id="add-form" method="post">
			<table>
				<tr>
					<td>图书编号</td>
					<td><input name="bNum" class="easyui-validatebox"
						data-options="required:true" /></td>
					<td>图书名称</td>
					<td><input name="bName" class="easyui-validatebox"
						data-options="required:true" /></td>

				</tr>
				<tr>
					<td>图书单价</td>
					<td><input name="price" class="easyui-validatebox"
						data-options="required:true" /></td>
					<td>出版社</td>
					<td><input name="publish" class="easyui-validatebox"
						data-options="required:true" /></td>

				</tr>
				<tr>
					<td>图书类型</td>
					<td><input name="categoryId" class="easyui-combobox"
						data-options="required:true,valueField:'categoryId',textField:'categoryName',url:'../findCategoryAllInfo'" /></td>
					<td>作者</td>
					<td><input name="author" class="easyui-validatebox"
						data-options="required:true" /></td>

				</tr>
				<tr>
					<td>数量</td>
					<td><input name="quantity" class="easyui-validatebox"
						data-options="required:true" /></td>

					<td>出版日期</td>
					<td><input name="publishDate" class="easyui-validatebox"
						data-options="required:true" /></td>

				</tr>

				<tr>
					<td>简介</td>
					<td><textarea rows="" cols="" name="introduction"></textarea></td>

				</tr>


			</table>
		</form>

	</div>

</body>
</html>